﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Kojarskiy.Core;
using Kojarskiy.Models;
using Mvc.Mailer;
using System.Net.Mail;

namespace Kojarskiy.Core
{ 
    public class MailSender : MailerBase    
	{
        public MailSender() : base()
		{
            MasterName = "_MailTemplate";
		}

        public virtual MvcMailMessage MailMessage(string ServiceType, string ClientName, string Address, string Phone, string Email, string Request)
        {
            ViewBag.ServiceType = ServiceType;
            ViewBag.ClientName = ClientName;
            ViewBag.Address = Address;
            ViewBag.Phone = Phone;
            ViewBag.Email = Email;
            ViewBag.Request = Request;

            var mailMessage = new MvcMailMessage { Subject = "Вопрос с сайта" };
            foreach (var email in SettingsManager.SmtpSettings.AdminEmail.Split(','))
            {
                mailMessage.To.Add(email);    
            }
            
            mailMessage.From = new MailAddress(SettingsManager.SmtpSettings.SmtpUser);
            PopulateBody(mailMessage, viewName: "_MailMessage");
            return mailMessage;
        }		
	}
}